//package com.example.config;
//
//import org.slf4j.LoggerFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import ch.qos.logback.classic.Logger;
//import ch.qos.logback.classic.LoggerContext;
//import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
//import ch.qos.logback.classic.spi.ILoggingEvent;
//import ch.qos.logback.core.ConsoleAppender;
//
//@Configuration
//public class LoggingConfig {
//
//    // 配置控制台日志输出格式（注解方式配置Logback）
//    @Bean
//    public ConsoleAppender<ILoggingEvent> consoleAppender() {
//        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
//
//        // 日志格式：时间 级别 线程 类名:行号 - 消息
//        PatternLayoutEncoder encoder = new PatternLayoutEncoder();
//        encoder.setPattern("%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [%thread] %logger{50}:%L - %msg%n");
//        encoder.setContext(loggerContext);
//        encoder.start();
//
//        ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
//        appender.setEncoder(encoder);
//        appender.setContext(loggerContext);
//        appender.start();
//
//        // 设置root日志级别为INFO
//        Logger rootLogger = loggerContext.getLogger("root");
//        rootLogger.setLevel(ch.qos.logback.classic.Level.INFO);
//        rootLogger.addAppender(appender);
//
//        return appender;
//    }
//}